//
//  RCSocketAcceptSerializationer.m
//  RCNetRequestProject
//
//  Created by kabu on 2017/8/15.
//  Copyright © 2017年 RC. All rights reserved.
//

#import "RCSocketAcceptSerializationer.h"

@implementation RCSocketAcceptSerializationer
+ (instancetype)serializationer{
    RCSocketAcceptSerializationer *ser = [[RCSocketAcceptSerializationer alloc]init];
    
    return ser;
}
- (id)transformMessageToResult:(NSData*)acceptData{
    NSString *result=[[NSString alloc]initWithData:acceptData encoding:NSUTF8StringEncoding];
    if (result) {
        return result;
    }
    return acceptData;
}
@end
@implementation RCJsonSocketAcceptSerializationer
+ (instancetype)serializationer{
    RCJsonSocketAcceptSerializationer *ser = [[RCJsonSocketAcceptSerializationer alloc]init];
    
    return ser;
}
- (id)transformMessageToResult:(NSData *)acceptData{
    NSError *error;
    NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:acceptData options:NSJSONReadingMutableLeaves error:&error];
    if (!error) {
        return  dict;
    }
    return  [super transformMessageToResult:acceptData];
}

@end
